<style scoped  lang="less">
.demo-Circle-custom{
    & h1{
        color: #3f414d;
        font-size: 28px;
        font-weight: normal;
    }
    & p{
        color: #657180;
        font-size: 14px;
        margin: 10px 0 15px;
    }
    & span{
        display: block;
        padding-top: 15px;
        color: #657180;
        font-size: 14px;
        &:before{
            content: '';
            display: block;
            width: 50px;
            height: 1px;
            margin: 0 auto;
            background: #e0e3e6;
            position: relative;
            top: -15px;
        };
    }
    & span i{
        font-style: normal;
        color: #3f414d;
    }
}
</style>
<template>
<div>
    <Card :bordered="false" dis-hover>
        <p slot="title">新闻列表</p>
        <Row :gutter="20">
            <Col span="6">
                <Input v-model="search.paramData.title" placeholder="标题" ></Input>
            </Col>
            <!-- <Col span="8">
                <RadioGroup v-model="search.paramData.reqType" type="button">
                    <Radio label="">全部</Radio>
                    <Radio label="red">红冲</Radio>
                    <Radio label="blue">开票</Radio>
                    <Radio label="rz">认证</Radio>
                    <Radio label="vali">查验</Radio>
                </RadioGroup>
            </Col> -->
            <!-- <Col span="10">
                <DatePicker type="datetimerange" format="yyyy-MM-dd" 
                placeholder="开票日期" v-model="search.paramData.date"
                @on-change="(r)=>{search.paramData.date=r}" style="width:100%;"></DatePicker>
            </Col> -->
            <Col span="2">
                <Button type="primary" icon="ios-search" @click="getdata('search')">搜索</Button>
            </Col>
            <Col span="2">
                <Button type="primary" icon="ios-search" @click="add">添加</Button>
            </Col>
        </Row>

        
        <br/>
        <div class="ivu-table-wrapper" >
            <div class="ivu-table ivu-table-with-fixed-top ">
                
                <div class="ivu-table-body" >
                    <table class="table_border _table"  cellspacing="0" cellpadding="0" border="0" style="width: 100%;">
                        
                        <thead>
                            <tr>
                                <th class="">
                                    <div class="ivu-table-cell">
                                        <span>标题</span>
                                    </div>
                                </th>
                                <th class="">
                                    <div class="ivu-table-cell">
                                        <span>创建时间</span>
                                    </div>
                                </th>
                                <th class="" style="width:100px;">
                                    <div class="ivu-table-cell">
                                        <span>浏览量</span>
                                    </div>
                                </th>
                                <th class="">
                                    <div class="ivu-table-cell">
                                        <span>来源</span>
                                    </div>
                                </th>
                                <th class="" >
                                    <div class="ivu-table-cell">
                                        <span>管理</span>
                                    </div>
                                </th>
                            </tr>
                        </thead>
                        <tbody class="ivu-table-tbody" v-for="item in data">
                            <tr class="ivu-table-row">
                                <td class="">
                                    <div class="ivu-table-cell">
                                        <span>
                                            {{item.title}}</span>
                                    </div>
                                </td>
                                <td class="">
                                    <div class="ivu-table-cell">
                                        <span>{{item.time |  formatDate('yyyy-MM-dd hh:mm:ss')  }}</span>
                                    </div>
                                </td>
                                <td class="">
                                    <div class="ivu-table-cell" >
                                        <span  >
                                            {{item.amount}}
                                        </span>
                                    </div>
                                </td>
                                <td class="">
                                    <div class="ivu-table-cell">
                                        <span >
                                            {{item.source}}
                                        </span>
                                    </div>
                                </td>
                                <td class="">
                                    <div class="ivu-table-cell">
                                        <Button  size="small" type="error" 
                                        @click="deleteuser(item)">删除</Button>
                                        <Button  size="small" type="warning" 
                                        @click="updateuser(item)">修改</Button>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="body_empty" v-if="data.length==0 ">
                        暂无数据
                    </div>
                </div>
            </div>
            
        </div>
        <p style="margin-top:10px;">
            <Page  show-total :page-size="search.pageSize" :current="search.pageNo"   :total="page.total" 
            show-total @on-change="changePage" style="float:right;"></Page>
        </p>
    </Card>
</div>	
</template>
<script>
export default {
    data (){
        return {
            check:false,
            page:{pageSize:2,total:0},
            search:{pageNo:1,pageSize:10,paramData:{title:null}},
            data:[
                
            ]
        }
    },methods:{
        add(){
            this.$router.push('/peport/newsadd')
        },
        changePage (pageNum){
            this.search.pageNo = pageNum;
            this.getdata();
        },getdata(type){
            if(type=='search'){
                this.search.pageNo=1;
            }
            this.axios.post('/new/list',
                this.search).then((res)=>{
                console.log(res);
                //this.data=res.data.list;
                var d=res.data.list;
                this.data=res.data.list;
                this.page.total=res.data.total;
                this.search.pageNo=res.data.pageNo || 1;
            })
        },checkchange(item){
            this.data.forEach(function(val){
                val.check=item;
            })
        },deleteuser(item){
            this.$Modal.confirm({
                 title:'删除提示',
                 content: '<p>确定删除？</p>',
                 onOk:()=>{
                     this.axios.post('/new/remove/'+item._id,{}).then((res)=>{
                        if(res.errorCode==0){
                            this.$Message.info(res.message);
                            this.page.currentPage=1;
                            this.getdata();
                        }
                        
                    })
                }
            })
        },updateuser(item){
            this.$router.push('/peport/newsadd?id='+item._id)
        }
    },mounted(){
        $('._table').resizableColumns({});
    },created(){
        this.getdata();
    },activated(){
        this.getdata();
    }
}
</script>